<template>
	<view >
		<!-- <view class="main-header">
			<view class="main-project  uni-ellipsis">
				<view class="uni-font-32" >
					<text >{{hasLogin}}---{{hasBoundHouse}}</text>
					<text v-show="hasLogin !== true" @click="login()">请登录</text>
					<text v-show="hasLogin === true && hasBoundHouse !== true" @click="toBindHouse()">请绑定房产</text>
					<view v-show="hasLogin === true && hasBoundHouse === true && myHouse.ownerInfo.villagename">
						<image src="/static/images/addr.png" mode="aspectFit" style="width: 30upx;height: 30upx;margin-right: 10upx;vertical-align: middle;"></image>
						<text style="vertical-align: middle;font-weight: 600;">{{ myHouse.ownerInfo.villagename }}</text>
					</view>
				</view>
			</view>
		</view> -->
		<block v-for="(item, index) in dataList" :key="index">
			<carousel  v-if="item.type == 'carousel'" :res="item.list" :listStyle="item.style"/>
			<menuSingleOne v-if="item.type == 'menuSingleOne'"  :res="item.data" :listStyle="item.style"/>
			<menuLayout v-if="item.type == 'menu'" :res="item.list" :listStyle="item.style"/>
			<menu4x v-if="item.type == 'menu4x'" :res="item.list" :listStyle="item.style"/>
			<card v-if="item.type == 'card'" :res="item.list" :listStyle="item.style"/>
		</block>
		
		<!-- <view class="address xztv-row xztv-col-center" v-if="address!=''">
			<view style="height:32rpx;display: flex;">
				<image src="../../static/position.png" style="width:28rpx;height:32rpx;"/>
			</view>
			<view style="height:24rpx;display: flex;margin-left:4rpx;">
				<text style="color:white;font-size: 24rpx;line-height: 24rpx;;">{{address}}</text>
			</view>
		</view> -->
	</view>
</template>

<script>
	import tpl_banner from "@/pages/index/template/tpl_banner"; //轮播图模块
	import tpl_menu_single_one from "@/pages/index/template/tpl_menu_single_one.vue"; //首页视频直播
	import tpl_menu from "@/pages/index/template/tpl_menu.vue"; //菜单模块
	import tpl_menu4x from "@/pages/index/template/tpl_menu4x.vue"; 
	import tpl_card from "@/pages/index/template/tpl_card.vue"; 
	import storage from "@/utils/storage.js";
	import { getIndexData } from '@/api/index'
	export default {
		components: {
			carousel: tpl_banner,
			menuSingleOne: tpl_menu_single_one,
			menuLayout:tpl_menu,
			menu4x:tpl_menu4x,
			card:tpl_card
		},
		data() {
			return {
				title: 'Hello',
				bannerList:[
					{img:"https://www.hzymt.zfbzhsq.com/static/applet/images/banner1.webp"},
					{img:"https://www.hzymt.zfbzhsq.com/static/applet/images/banner2.webp"}
				],
				bannerStyle:{
					
				},
				address:"",
				dataList:[],
				hasBoundHouse:false,
				hasLogin:false,
			}
		},
		onLoad() {
			this.getData();
			let that=this;
		},
		onPullDownRefresh() {
			storage.setHasLogin(false);
			storage.setAccessToken("");
			storage.setBouseHouse(false);
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onShow(){
			if(storage.getBouseHouse()==true){
				this.hasBoundHouse=storage.getBouseHouse()
			}
			if(storage.getHasLogin()==true){
				this.hasLogin=storage.getHasLogin();
			}
		},
		computed: {
			myHouse() {
				return this.$store.state.myHouse;
			},
		},
		methods: {
			toBindHouse(){
				this.$to(`/pages/bound-house/bound-house`);
			},
			getData(){
				getIndexData().then((res)=>{
					if(res.data.code==0){
						this.dataList=res.data.data
					}
					console.log("getBanner",res);
				})
			},
			login(){
				// #ifdef MP-WEIXIN
				uni.navigateTo({
					url: "/pages/login/wechatMPLogin",
				});
				// #endif
				// #ifdef MP-ALIPAY
				uni.navigateTo({
					url: "/pages/login/aliMPLogin",
				});
				// #endif
			},
		}
	}
</script>

<style>
	.main-header {
		background-color: red;
		height: 150rpx;
		width: 100%;
		
		padding-left: 20rpx;
		box-sizing: border-box;
		background: #ffffff;
	}
	.main-project {
		padding-top: 70rpx;
	}
	.xztv-row {
		display: flex;
		flex-direction: row;
	}
	
	.xztv-column {
		display: flex;
		flex-direction: column;
	}
	.xztv-col-center {
		align-items: center;
	}
	.xztv-row-center {
		justify-content: center;
	}
	/* 垂直居中 */
	.xztv-vertical-center {
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		width:750rpx;
		position: relative;
	}
	.address{
		position: absolute;
		height:40rpx;
		top:10rpx;
		right:40rpx;
		background-color: rgba(0, 0, 0, 0.5);
		padding-left: 10rpx;
		padding-right: 10rpx;
		border-radius: 8rpx;
	}
	

	
</style>
